home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / demo / demosrc / widtips.pro < prev   
Text File  |  1997-07-08  |  2KB  |  75 lines

  1. ;--------------------------------------------------
  2. ;
  3. ;    PURPOSE  Create widget text for information.
  4. ;             It can be used in conjuction with
  5. ;             the routines <<gettips.pro>> and
  6. ;             <<puttips.pro>>.
  7. ;
  8. pro widtips, $
  9.     wParentBase, $         ; IN: parent base identifer
  10.     textArray, $           ; IN: text array to be displayed.
  11.     XSIZE= xSize, $        ; IN: (opt) widget x size (in characters)
  12.     YSIZE= ySize, $        ; IN: (opt) widget y size (in characters)
  13.     NWIDGETS= nWidgets, $  ; IN: (opt) number of widget text to create
  14.     WIDGETID               ; OUT: widget identifer
  15.  
  16.     ;  Check the validity of the input parameters.
  17.     ;
  18.     if (N_ELEMENTS(wParentBase) EQ 0) then begin
  19.         PRINT,'Error in widtips.pro : you must pass a parent base.'
  20.         RETURN
  21.     endif
  22.  
  23.     ;  Set the default value of the optional parameters.
  24.     ;
  25.     if (N_ELEMENTS(xSize) EQ 0) then begin
  26.         xSize = 40
  27.     endif
  28.     if (N_ELEMENTS(ySize) EQ 0) then begin
  29.         ySize = 3
  30.     endif
  31.     if (N_ELEMENTS(nWidgets) EQ 0) then begin
  32.         nWidgets = 1
  33.     endif
  34.  
  35.     ;  For the demo purposes only, set the x size to 43.
  36.     ;  Maximumn number of cahracters per line is 42.
  37.     ;
  38.     xSize = 43
  39.  
  40.     ;  Create the widget id array.
  41.     ;
  42.     widgetID = LONARR(nWidgets)
  43.  
  44.     ;  Get the geometry of the top level base.
  45.     ;
  46.     tlbGeom = WIDGET_INFO(wParentBase, /GEOMETRY) 
  47.  
  48.     tlbXSize = tlbgeom.scr_xsize + (2 * tlbgeom.margin)
  49.     tlbYSize = tlbgeom.scr_ysize + (2 * tlbgeom.margin)
  50.  
  51.     ;  Verify that the textArray size is big enough.
  52.     ;
  53.     sztext = size(textArray)
  54.     nMin = nWidgets*ysize
  55.     if (sztext[1] LT nMin) then begin
  56.         PRINT, 'Error in widtips.pro : The text Array must have a'
  57.         PRINT, 'minimum of  ', nMin, ' elements.'
  58.         PRINT, 'It currently has ', szText[1], ' elements'
  59.         RETURN
  60.     endif
  61.  
  62.     ;  Create the widgets.
  63.     ;  Notice the value of the text. It assign the text value
  64.     ;  from the initial textArray successively.
  65.     ;
  66.     for i = 0, nWidgets-1  do begin
  67.         textValue = textArray[ i*ysize : (i+1)*ysize-1]
  68.  
  69.         widgetID[i] = WIDGET_TEXT(wParentBase, $
  70.             VALUE=textValue, $
  71.             XSIZE=xsize, YSIZE=ysize)
  72.     endfor
  73.  
  74. end   ;   of widtips.pro
  75.